home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9070 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  50 lines

  1. Path: ix.netcom.com!netnews
  2. From: ave@ix.netcom.com(Alexander Berdichevsky )
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Argc & Argv
  5. Date: 28 Feb 1996 13:36:52 GMT
  6. Organization: Netcom
  7. Message-ID: <4h1lpk$dg7@cloner4.netcom.com>
  8. References: <4gta9f$df5@netlab.cs.rpi.edu>
  9. NNTP-Posting-Host: ix-prn1-07.ix.netcom.com
  10. X-NETCOM-Date: Wed Feb 28  5:36:52 AM PST 1996
  11.  
  12.  
  13. >I have some global objects defined outside the main routine and I
  14. would
  15. >like to pass the argc and argv values to their constructors.  For
  16. example,
  17. >SomeClass obj( argc, argv);
  18. >int main( int argc, char **argv) {
  19. >   blah, blah, blah
  20. >}
  21. >Unfortunately, the compiler tells me that argc and argv are not
  22. defined
  23. >or else not available for obj.
  24. >Currently, I get around this problem by creating the global obj and
  25. then
  26. >inside of main, I initialize obj via a method that takes argc and
  27. argv.  
  28. >I would prefer to pass the arg vars to the constructor.  Does anyone
  29. know
  30. >how I can pass the arg vars without being inside of main?
  31.  
  32. 1. All dynamical initialization for global variables are before main
  33. function;
  34. 2. argc and argv dynamically passed to the main function from a command
  35. line;
  36.  
  37. Therefore you can not use them before main function started.
  38.  
  39. Best regards
  40.  
  41. Alex
  42.